package com.punch.oauth.exception;

import com.punch.common.exception.DefaultExceptionAdvice;
import com.punch.common.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.oauth2.common.exceptions.BadClientCredentialsException;
import org.springframework.security.oauth2.provider.NoSuchClientException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @author mall
 * @date 2018/12/22
 */
@ControllerAdvice
@Slf4j
public class ExceptionAdvice extends DefaultExceptionAdvice {

    /**
     * IllegalArgumentException异常处理返回json
     * 返回状态码:400
     */
    @ExceptionHandler({BadClientCredentialsException.class})
    public Result noSuchClientException(BadClientCredentialsException e) {
        return Result.failed(e.getMessage());
    }
}
